#!/usr/bin/env node

const mysql = require('mysql2/promise'),
      log = console.log;

let con = mysql.createConnection({
  host:'localhost',
    user:'root',
    passward:'ddd',
    database:'test'
});
getAreas();

async function getAreas(){
  const sql = `select * from area`;
  let [result] = await con.execute(sql);
  log(result);
}

async function addAreas(areaName){
  const sql = `insert into area (area_name) values('${areaName}')`;
  let [rews] = await con.execute(sql);
  return rews;
}

async function updateAreas(oldName,newName){
  const sql = `update area set area_name = '${newName}' where area_name = '${oldName}'`;
  let [rews] = await con.execute(sql);
  return rews;
}

async function deleteAreas(areaName){
  const sql = `delete from area where area_name = '${areaName}'`;
  let [rews] = await con.execute(sql);
  return rews;
}


(async function(){
  await deleteAreas('日韩');
  console.log(await getAreas());
})();

